package com.fr.dialog;

import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Inter;
import com.fr.base.core.BaseCoreUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.cell.GUIUtils;
import com.fr.cell.core.GUICoreUtils;
import com.fr.cell.core.layout.LayoutFactory;
import com.fr.dialog.core.ColumnRowPane;
import com.fr.dialog.core.ReportPageAttrPane;
import com.fr.dialog.core.UnitFieldPane;
import com.fr.report.Margin;
import com.fr.report.PaperSize;
import com.fr.report.Report;
import com.fr.report.ReportConstants;
import com.fr.report.ReportSettings;
import com.fr.report.core.ReportUtils;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Window;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.JTabbedPane;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

public class PageSetupDialog extends BaseDialog
{
  private PagePane pagePane;
  private OtherPane otherPane;
  private JPanel controlButtonPane;
  private boolean useLocale = false;

  public static PageSetupDialog showWindow(Window paramWindow)
  {
    if (paramWindow instanceof Frame)
      return new PageSetupDialog((Frame)paramWindow);
    return new PageSetupDialog((Dialog)paramWindow);
  }

  protected PageSetupDialog(Frame paramFrame)
  {
    super(paramFrame);
    initComponents();
  }

  protected PageSetupDialog(Dialog paramDialog)
  {
    super(paramDialog);
    initComponents();
  }

  protected void initComponents()
  {
    super.initComponents();
    JPanel localJPanel = (JPanel)getContentPane();
    JTabbedPane localJTabbedPane = new JTabbedPane();
    localJPanel.add(localJTabbedPane, "Center");
    this.pagePane = new PagePane(this);
    this.otherPane = new OtherPane(this);
    localJTabbedPane.addTab(Inter.getLocText("PageSetup-Page"), this.pagePane);
    localJTabbedPane.addTab(Inter.getLocText("Other"), this.otherPane);
    this.controlButtonPane = createControlButtonPane();
    localJPanel.add(this.controlButtonPane, "South");
    setTitle(Inter.getLocText("PageSetup-Page_Setup"));
    setSize(420, 480);
    setModal(true);
    GUIUtils.centerWindow(this);
  }

  public void populate(Report paramReport)
  {
    if (paramReport == null)
      return;
    this.pagePane.populate(ReportUtils.getReportSettings(paramReport));
    this.otherPane.populate(paramReport);
  }

  public void update(Report paramReport)
  {
    if (paramReport == null)
      return;
    this.pagePane.update(paramReport);
    this.otherPane.update(paramReport);
  }

  public void checkValid()
    throws Exception
  {
    super.checkValid();
  }

  static boolean access$000(PageSetupDialog paramPageSetupDialog)
  {
    return paramPageSetupDialog.useLocale;
  }

  class OtherPane extends JPanel
  {
    private JRadioButton topBottomRadioButton;
    private JRadioButton leftRightRadioButton;
    private JCheckBox horizonalCenterCheckBox;
    private JCheckBox verticalCenterCheckBox;
    private JSpinner firstPageNumberSpinner;
    private JCheckBox freezeCheckBox;
    private CardLayout freezeCard;
    private JPanel freezeShowPane;
    private ColumnRowPane frozenColumnRow;
    private ReportPageAttrPane reportPageAttrPane;
    private JRadioButton isShrinkToFit4None;
    private JRadioButton isShrinkToFit4Height;
    private JRadioButton isShrinkToFit4Width;
    private JCheckBox singlePagePrint;
    private final PageSetupDialog this$0;

    public OtherPane()
    {
      this.this$0 = paramPageSetupDialog;
      setLayout(LayoutFactory.createBorderLayout());
      JPanel localJPanel1 = new JPanel();
      add(localJPanel1, "North");
      localJPanel1.setLayout(new BoxLayout(localJPanel1, 1));
      JPanel localJPanel2 = new JPanel();
      localJPanel1.add(localJPanel2);
      localJPanel2.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Page_Order")));
      localJPanel2.setLayout(new GridLayout(1, 2));
      Icon localIcon1 = BaseUtils.readIcon("/com/fr/dialog/images/pagesetup/down.png");
      this.topBottomRadioButton = new JRadioButton(Inter.getLocText("PageSetup-Top_to_bottom"));
      localJPanel2.add(createIconRadioPane(localIcon1, this.topBottomRadioButton));
      this.topBottomRadioButton.setMnemonic('B');
      Icon localIcon2 = BaseUtils.readIcon("/com/fr/dialog/images/pagesetup/over.png");
      this.leftRightRadioButton = new JRadioButton(Inter.getLocText("PageSetup-Left_to_right"));
      localJPanel2.add(createIconRadioPane(localIcon2, this.leftRightRadioButton));
      this.leftRightRadioButton.setMnemonic('R');
      ButtonGroup localButtonGroup1 = new ButtonGroup();
      localButtonGroup1.add(this.topBottomRadioButton);
      localButtonGroup1.add(this.leftRightRadioButton);
      this.topBottomRadioButton.setSelected(true);
      JPanel localJPanel3 = new JPanel();
      localJPanel1.add(localJPanel3);
      localJPanel3.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Placement_Center_on_Page")));
      localJPanel3.setLayout(new GridLayout(1, 2));
      this.horizonalCenterCheckBox = new JCheckBox(Inter.getLocText("PageSetup-Horizontally"));
      this.horizonalCenterCheckBox.setMnemonic('H');
      this.verticalCenterCheckBox = new JCheckBox(Inter.getLocText("PageSetup-Vertically"));
      this.verticalCenterCheckBox.setMnemonic('V');
      localJPanel3.add(GUICoreUtils.createFlowPane(this.horizonalCenterCheckBox, 1));
      localJPanel3.add(GUICoreUtils.createFlowPane(this.verticalCenterCheckBox, 1));
      this.singlePagePrint = new JCheckBox("单页打印");
      JPanel localJPanel4 = GUICoreUtils.createFlowPane(this.singlePagePrint, 1);
      localJPanel4.setBorder(BorderFactory.createTitledBorder("打印设置"));
      localJPanel1.add(localJPanel4);
      JPanel localJPanel5 = new JPanel();
      localJPanel1.add(localJPanel5);
      localJPanel5.setLayout(new FlowLayout(0, 2, 5));
      localJPanel5.add(new JLabel(Inter.getLocText("PageSetup-First_Page_Number") + ": "));
      this.firstPageNumberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 2147483647, 1));
      JFormattedTextField localJFormattedTextField = ((JSpinner.DefaultEditor)this.firstPageNumberSpinner.getEditor()).getTextField();
      localJFormattedTextField.setColumns(2);
      localJPanel5.add(this.firstPageNumberSpinner);
      localJPanel1.add(Box.createVerticalStrut(4));
      this.reportPageAttrPane = new ReportPageAttrPane();
      localJPanel1.add(this.reportPageAttrPane);
      JPanel localJPanel6 = new JPanel();
      localJPanel1.add(localJPanel6);
      localJPanel6.setLayout(new FlowLayout(0, 4, 2));
      localJPanel6.add(new JLabel(Inter.getLocText("Freeze-Use_In_Write") + ":"));
      localJPanel6.add(this.freezeCheckBox = new JCheckBox());
      this.freezeCard = new CardLayout();
      this.freezeShowPane = new JPanel(this.freezeCard);
      this.freezeShowPane.add("none", new JPanel());
      this.frozenColumnRow = new ColumnRowPane();
      this.freezeShowPane.add("frozen", this.frozenColumnRow);
      localJPanel6.add(this.freezeShowPane);
      this.freezeCheckBox.addActionListener(new PageSetupDialog.6(this));
      localJPanel1.add(Box.createVerticalStrut(4));
      JPanel localJPanel7 = new JPanel();
      localJPanel1.add(localJPanel7);
      localJPanel7.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
      localJPanel7.setLayout(new GridLayout(1, 1, 0, 0));
      JPanel localJPanel8 = new JPanel();
      localJPanel8.setLayout(new FlowLayout(0, 5, 0));
      localJPanel8.add(new JLabel(Inter.getLocText("PageSetup-Shrink_to_fit_content")));
      this.isShrinkToFit4None = new JRadioButton(Inter.getLocText("No"));
      this.isShrinkToFit4Height = new JRadioButton(Inter.getLocText("Utils-Row_Height"));
      this.isShrinkToFit4Width = new JRadioButton(Inter.getLocText("Utils-Column_Width"));
      ButtonGroup localButtonGroup2 = new ButtonGroup();
      localJPanel8.add(this.isShrinkToFit4None);
      localJPanel8.add(this.isShrinkToFit4Height);
      localJPanel8.add(this.isShrinkToFit4Width);
      localButtonGroup2.add(this.isShrinkToFit4None);
      localButtonGroup2.add(this.isShrinkToFit4Height);
      localButtonGroup2.add(this.isShrinkToFit4Width);
      localJPanel7.add(localJPanel8);
    }

    private JPanel createIconRadioPane(, JRadioButton paramJRadioButton)
    {
      JPanel localJPanel = new JPanel();
      localJPanel.setLayout(new FlowLayout(1));
      localJPanel.add(new JLabel(paramIcon));
      localJPanel.add(paramJRadioButton);
      return localJPanel;
    }

    public void populate()
    {
      ReportSettings localReportSettings = null;
      localReportSettings = ReportUtils.getReportSettings(paramReport);
      if (localReportSettings == null)
        localReportSettings = new ReportSettings();
      if (localReportSettings.getPageOrder() == 1)
        this.leftRightRadioButton.setSelected(true);
      else
        this.topBottomRadioButton.setSelected(true);
      this.horizonalCenterCheckBox.setSelected(localReportSettings.isHorizontalCenterOnPage());
      this.verticalCenterCheckBox.setSelected(localReportSettings.isVerticalCenterOnPage());
      this.firstPageNumberSpinner.setValue(new Integer(localReportSettings.getFirstPageNumber()));
      if (localReportSettings.getWriteFrozenColumnRow() != null)
      {
        this.freezeCheckBox.setSelected(true);
        this.freezeCard.show(this.freezeShowPane, "frozen");
        this.frozenColumnRow.populate(localReportSettings.getWriteFrozenColumnRow());
      }
      this.reportPageAttrPane.populate(paramReport.getReportPageAttr());
      if (localReportSettings.getShrinkToFitMode() == 2)
        this.isShrinkToFit4Width.setSelected(true);
      else if (localReportSettings.getShrinkToFitMode() == 1)
        this.isShrinkToFit4Height.setSelected(true);
      else
        this.isShrinkToFit4None.setSelected(true);
      this.singlePagePrint.setSelected(localReportSettings.isLonelyPage());
    }

    public void update()
    {
      ReportSettings localReportSettings = null;
      if (paramReport.getReportSettings() == null)
        paramReport.setReportSettings(new ReportSettings());
      localReportSettings = paramReport.getReportSettings();
      if (this.leftRightRadioButton.isSelected())
        localReportSettings.setPageOrder(1);
      else
        localReportSettings.setPageOrder(0);
      localReportSettings.setHorizontalCenterOnPage(this.horizonalCenterCheckBox.isSelected());
      localReportSettings.setVerticalCenterOnPage(this.verticalCenterCheckBox.isSelected());
      localReportSettings.setFirstPageNumber(((Integer)this.firstPageNumberSpinner.getValue()).intValue());
      paramReport.setReportPageAttr(this.reportPageAttrPane.update());
      if (this.freezeCheckBox.isSelected())
        localReportSettings.setWriteFrozenColumnRow(this.frozenColumnRow.update());
      else
        localReportSettings.setWriteFrozenColumnRow(null);
      if (this.isShrinkToFit4Width.isSelected())
        localReportSettings.setShrinkToFitMode(2);
      else if (this.isShrinkToFit4Height.isSelected())
        localReportSettings.setShrinkToFitMode(1);
      else
        localReportSettings.setShrinkToFitMode(0);
      localReportSettings.setLonelyPage(this.singlePagePrint.isSelected());
    }

    static JCheckBox access$800(OtherPane paramOtherPane)
    {
      return paramOtherPane.freezeCheckBox;
    }

    static JPanel access$900(OtherPane paramOtherPane)
    {
      return paramOtherPane.freezeShowPane;
    }

    static CardLayout access$1000(OtherPane paramOtherPane)
    {
      return paramOtherPane.freezeCard;
    }
  }

  class PagePane extends JPanel
  {
    private JRadioButton portraitRadioButton;
    private JRadioButton landscapeRadioButton;
    private JRadioButton predefinedRadioButton;
    private JRadioButton customRadioButton;
    private JComboBox predefinedComboBox;
    private JSpinner paperWidthSpinner;
    private JSpinner paperHeightSpinner;
    private UnitFieldPane marginTopUnitFieldPane;
    private UnitFieldPane marginLeftUnitFieldPane;
    private UnitFieldPane marginBottomUnitFieldPane;
    private UnitFieldPane marginRightUnitFieldPane;
    private UnitFieldPane headerUnitFieldPane;
    private UnitFieldPane footerUnitFieldPane;
    private ShowPagePane showPagePane;
    private ActionListener previewListener;
    private ChangeListener previewListener2;
    private DefaultListCellRenderer paperSizeCellRenderere;
    private ItemListener paperSizeItemListener;
    DocumentListener customTextListener;
    private final PageSetupDialog this$0;

    public PagePane()
    {
      this.this$0 = paramPageSetupDialog;
      this.previewListener = new PageSetupDialog.1(this);
      this.previewListener2 = new PageSetupDialog.2(this);
      this.paperSizeCellRenderere = new PageSetupDialog.3(this);
      this.paperSizeItemListener = new PageSetupDialog.4(this);
      this.customTextListener = new PageSetupDialog.5(this);
      setLayout(new BorderLayout());
      JPanel localJPanel1 = new JPanel();
      add(localJPanel1, "North");
      localJPanel1.setLayout(new BoxLayout(localJPanel1, 1));
      JPanel localJPanel2 = new JPanel();
      localJPanel1.add(localJPanel2);
      localJPanel2.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Orientation")));
      localJPanel2.setLayout(new GridLayout(1, 2));
      Icon localIcon1 = BaseUtils.readIcon("/com/fr/dialog/images/pagesetup/portrait.png");
      this.portraitRadioButton = new JRadioButton(Inter.getLocText("PageSetup-Portrait"));
      this.portraitRadioButton.setMnemonic('t');
      localJPanel2.add(createIconRadioPane(localIcon1, this.portraitRadioButton));
      this.portraitRadioButton.addActionListener(this.previewListener);
      Icon localIcon2 = BaseUtils.readIcon("/com/fr/dialog/images/pagesetup/landScape.png");
      this.landscapeRadioButton = new JRadioButton(Inter.getLocText("PageSetup-Landscape"));
      this.landscapeRadioButton.setMnemonic('L');
      localJPanel2.add(createIconRadioPane(localIcon2, this.landscapeRadioButton));
      this.landscapeRadioButton.addActionListener(this.previewListener);
      ButtonGroup localButtonGroup = new ButtonGroup();
      localButtonGroup.add(this.portraitRadioButton);
      localButtonGroup.add(this.landscapeRadioButton);
      this.portraitRadioButton.setSelected(true);
      JPanel localJPanel3 = new JPanel();
      localJPanel3.setLayout(new FlowLayout(1));
      this.showPagePane = new ShowPagePane(this);
      localJPanel3.add(this.showPagePane);
      localJPanel1.add(localJPanel3);
      localJPanel3.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Preview")));
      JPanel localJPanel4 = new JPanel();
      localJPanel1.add(localJPanel4);
      localJPanel4.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Paper_Size")));
      localJPanel4.setLayout(new BoxLayout(localJPanel4, 0));
      this.predefinedRadioButton = new JRadioButton(Inter.getLocText("PageSetup-Predefined") + ":");
      this.predefinedRadioButton.setMnemonic('P');
      this.predefinedRadioButton.addActionListener(this.previewListener);
      this.customRadioButton = new JRadioButton(Inter.getLocText("Custom") + ":");
      this.customRadioButton.setMnemonic('C');
      this.customRadioButton.addActionListener(this.previewListener);
      this.predefinedComboBox = new JComboBox();
      this.paperWidthSpinner = new JSpinner(new SpinnerNumberModel(0.0D, 0.0D, 1.7976931348623157E+308D, 1.0D));
      ((JSpinner.DefaultEditor)this.paperWidthSpinner.getEditor()).getTextField().setColumns(7);
      this.paperHeightSpinner = new JSpinner(new SpinnerNumberModel(0.0D, 0.0D, 1.7976931348623157E+308D, 1.0D));
      ((JSpinner.DefaultEditor)this.paperHeightSpinner.getEditor()).getTextField().setColumns(7);
      JLabel localJLabel = new JLabel();
      Locale localLocale = FRContext.getLocale();
      if (PageSetupDialog.access$000(paramPageSetupDialog))
        if (ComparatorUtils.equals(Locale.CHINA, localLocale))
          localJLabel.setText(Inter.getLocText("PageSetup-mm"));
        else
          localJLabel.setText(Inter.getLocText("PageSetup-inches"));
      else
        localJLabel.setText(Inter.getLocText("PageSetup-mm"));
      Dimension localDimension = new Dimension(localJLabel.getPreferredSize().width, this.paperHeightSpinner.getPreferredSize().height);
      localJLabel.setMinimumSize(localDimension);
      localJLabel.setMinimumSize(localDimension);
      localJLabel.setSize(localDimension);
      localJLabel.setPreferredSize(localDimension);
      this.predefinedComboBox.setRenderer(this.paperSizeCellRenderere);
      this.predefinedComboBox.addItemListener(this.paperSizeItemListener);
      ((JSpinner.DefaultEditor)this.paperWidthSpinner.getEditor()).getTextField().getDocument().addDocumentListener(this.customTextListener);
      ((JSpinner.DefaultEditor)this.paperHeightSpinner.getEditor()).getTextField().getDocument().addDocumentListener(this.customTextListener);
      this.paperWidthSpinner.addChangeListener(this.previewListener2);
      this.paperHeightSpinner.addChangeListener(this.previewListener2);
      for (int i = 0; i < ReportConstants.PaperSizeNameSizeArray.length; ++i)
      {
        localObject = ReportConstants.PaperSizeNameSizeArray[i];
        this.predefinedComboBox.addItem(localObject[1]);
      }
      localJPanel4.add(Box.createHorizontalStrut(8));
      JPanel localJPanel5 = new JPanel();
      localJPanel4.add(localJPanel5);
      localJPanel5.setLayout(new GridLayout(2, 1));
      localJPanel5.add(this.predefinedRadioButton);
      localJPanel5.add(this.customRadioButton);
      Object localObject = new ButtonGroup();
      ((ButtonGroup)localObject).add(this.predefinedRadioButton);
      ((ButtonGroup)localObject).add(this.customRadioButton);
      JPanel localJPanel6 = new JPanel();
      localJPanel4.add(localJPanel6);
      localJPanel6.setLayout(new GridLayout(2, 1));
      JPanel localJPanel7 = new JPanel();
      localJPanel6.add(localJPanel7);
      localJPanel7.setLayout(new FlowLayout(0, 4, 2));
      localJPanel7.add(this.predefinedComboBox);
      JPanel localJPanel8 = new JPanel();
      localJPanel8.setLayout(new FlowLayout(0, 4, 2));
      localJPanel8.add(this.paperWidthSpinner);
      localJPanel8.add(new JLabel("x"));
      localJPanel8.add(this.paperHeightSpinner);
      localJPanel8.add(localJLabel);
      localJPanel6.add(localJPanel8);
      localJPanel4.add(Box.createHorizontalStrut(12));
      JPanel localJPanel9 = new JPanel();
      localJPanel1.add(localJPanel9);
      localJPanel9.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PageSetup-Margin")));
      localJPanel9.setLayout(new GridLayout(1, 2));
      JPanel localJPanel10 = new JPanel();
      localJPanel9.add(localJPanel10);
      localJPanel10.setLayout(new FlowLayout(0, 4, 1));
      localJPanel10.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0));
      JPanel localJPanel11 = new JPanel();
      localJPanel10.add(localJPanel11);
      localJPanel11.setLayout(new GridLayout(2, 1, 1, 2));
      localJPanel11.add(new JLabel(Inter.getLocText("Top") + ":"));
      localJPanel11.add(new JLabel(Inter.getLocText("Bottom") + ":"));
      JPanel localJPanel12 = new JPanel();
      localJPanel10.add(localJPanel12);
      localJPanel12.setLayout(new GridLayout(2, 1, 1, 2));
      this.marginTopUnitFieldPane = new UnitFieldPane();
      this.marginBottomUnitFieldPane = new UnitFieldPane();
      localJPanel12.add(this.marginTopUnitFieldPane);
      localJPanel12.add(this.marginBottomUnitFieldPane);
      JPanel localJPanel13 = new JPanel();
      localJPanel9.add(localJPanel13);
      localJPanel13.setLayout(new FlowLayout(0, 4, 1));
      localJPanel13.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0));
      JPanel localJPanel14 = new JPanel();
      localJPanel13.add(localJPanel14);
      localJPanel14.setLayout(new GridLayout(2, 1, 1, 2));
      localJPanel14.add(new JLabel(Inter.getLocText("Left") + ":"));
      localJPanel14.add(new JLabel(Inter.getLocText("Right") + ":"));
      JPanel localJPanel15 = new JPanel();
      localJPanel13.add(localJPanel15);
      localJPanel15.setLayout(new GridLayout(2, 1, 1, 2));
      this.marginLeftUnitFieldPane = new UnitFieldPane();
      this.marginRightUnitFieldPane = new UnitFieldPane();
      localJPanel15.add(this.marginLeftUnitFieldPane);
      localJPanel15.add(this.marginRightUnitFieldPane);
      JPanel localJPanel16 = new JPanel();
      localJPanel16.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Height")));
      localJPanel1.add(localJPanel16);
      localJPanel16.setLayout(new GridLayout(1, 2));
      JPanel localJPanel17 = new JPanel();
      localJPanel16.add(localJPanel17);
      localJPanel17.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0));
      localJPanel17.setLayout(new FlowLayout(0, 4, 1));
      localJPanel17.add(new JLabel(Inter.getLocText("PageSetup-Header") + ":"));
      this.headerUnitFieldPane = new UnitFieldPane();
      localJPanel17.add(this.headerUnitFieldPane);
      JPanel localJPanel18 = new JPanel();
      localJPanel16.add(localJPanel18);
      localJPanel18.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0));
      localJPanel18.setLayout(new FlowLayout(0, 4, 1));
      localJPanel18.add(new JLabel(Inter.getLocText("PageSetup-Footer") + ":"));
      this.footerUnitFieldPane = new UnitFieldPane();
      localJPanel18.add(this.footerUnitFieldPane);
      JPanel localJPanel19 = new JPanel();
      localJPanel1.add(localJPanel19);
      localJPanel19.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
      localJPanel19.setLayout(new GridLayout(1, 1, 0, 0));
    }

    public void populate()
    {
      if (paramReportSettings.getOrientation() == 1)
        this.landscapeRadioButton.setSelected(true);
      else
        this.portraitRadioButton.setSelected(true);
      PaperSize localPaperSize = paramReportSettings.getPaperSize();
      if (localPaperSize == null)
        localPaperSize = PaperSize.PAPERSIZE_A4;
      int i = 0;
      for (int j = 0; j < ReportConstants.PaperSizeNameSizeArray.length; ++j)
      {
        Object[] arrayOfObject = ReportConstants.PaperSizeNameSizeArray[j];
        if (ComparatorUtils.equals(localPaperSize, arrayOfObject[1]))
        {
          this.predefinedComboBox.setSelectedIndex(j);
          this.predefinedRadioButton.setSelected(true);
          i = 1;
          break;
        }
      }
      if (i == 0)
      {
        this.customRadioButton.setSelected(true);
        localObject = FRContext.getLocale();
        if (PageSetupDialog.access$000(this.this$0))
        {
          if (ComparatorUtils.equals(Locale.CHINA, localObject))
          {
            this.paperWidthSpinner.setValue(new Double(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth())));
            this.paperHeightSpinner.setValue(new Double(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight())));
          }
          else
          {
            this.paperWidthSpinner.setValue(new Double(localPaperSize.getWidth()));
            this.paperHeightSpinner.setValue(new Double(localPaperSize.getHeight()));
          }
        }
        else
        {
          this.paperWidthSpinner.setValue(new Double(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth())));
          this.paperHeightSpinner.setValue(new Double(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight())));
        }
      }
      if (PageSetupDialog.access$000(this.this$0))
        if (ComparatorUtils.equals(Locale.CHINA, FRContext.getLocale()))
          this.showPagePane.populate(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth()), BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight()), paramReportSettings.getOrientation(), true);
        else
          this.showPagePane.populate(localPaperSize.getWidth(), localPaperSize.getHeight(), paramReportSettings.getOrientation(), false);
      else
        this.showPagePane.populate(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth()), BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight()), paramReportSettings.getOrientation(), true);
      Object localObject = paramReportSettings.getMargin();
      this.marginTopUnitFieldPane.setInchesValue(((Margin)localObject).getTop());
      this.marginLeftUnitFieldPane.setInchesValue(((Margin)localObject).getLeft());
      this.marginBottomUnitFieldPane.setInchesValue(((Margin)localObject).getBottom());
      this.marginRightUnitFieldPane.setInchesValue(((Margin)localObject).getRight());
      this.headerUnitFieldPane.setInchesValue(paramReportSettings.getHeaderHeight());
      this.footerUnitFieldPane.setInchesValue(paramReportSettings.getFooterHeight());
    }

    public void update()
    {
      ReportSettings localReportSettings = paramReport.getReportSettings();
      if (localReportSettings == null)
      {
        localReportSettings = new ReportSettings();
        paramReport.setReportSettings(localReportSettings);
      }
      if (this.landscapeRadioButton.isSelected())
        localReportSettings.setOrientation(1);
      else
        localReportSettings.setOrientation(0);
      if (this.predefinedRadioButton.isSelected())
      {
        try
        {
          localReportSettings.setPaperSize((PaperSize)((PaperSize)this.predefinedComboBox.getSelectedItem()).clone());
        }
        catch (CloneNotSupportedException localCloneNotSupportedException)
        {
        }
      }
      else if (this.customRadioButton.isSelected())
      {
        localObject = FRContext.getLocale();
        if (PageSetupDialog.access$000(this.this$0))
          if (ComparatorUtils.equals(Locale.CHINA, localObject))
            localReportSettings.setPaperSize(new PaperSize(BaseCoreUtils.convertMillimetersToInches(((Number)this.paperWidthSpinner.getValue()).doubleValue()), BaseCoreUtils.convertMillimetersToInches(((Number)this.paperHeightSpinner.getValue()).doubleValue())));
          else
            localReportSettings.setPaperSize(new PaperSize(((Number)this.paperWidthSpinner.getValue()).doubleValue(), ((Number)this.paperHeightSpinner.getValue()).doubleValue()));
        else
          localReportSettings.setPaperSize(new PaperSize(BaseCoreUtils.convertMillimetersToInches(((Number)this.paperWidthSpinner.getValue()).doubleValue()), BaseCoreUtils.convertMillimetersToInches(((Number)this.paperHeightSpinner.getValue()).doubleValue())));
      }
      Object localObject = localReportSettings.getMargin();
      ((Margin)localObject).setTop(this.marginTopUnitFieldPane.getInchesValue());
      ((Margin)localObject).setLeft(this.marginLeftUnitFieldPane.getInchesValue());
      ((Margin)localObject).setBottom(this.marginBottomUnitFieldPane.getInchesValue());
      ((Margin)localObject).setRight(this.marginRightUnitFieldPane.getInchesValue());
      localReportSettings.setHeaderHeight(this.headerUnitFieldPane.getInchesValue());
      localReportSettings.setFooterHeight(this.footerUnitFieldPane.getInchesValue());
    }

    private void previewShowPagePane()
    {
      int i;
      if (this.landscapeRadioButton.isSelected())
        i = 1;
      else
        i = 0;
      if (this.predefinedRadioButton.isSelected())
      {
        PaperSize localPaperSize = (PaperSize)this.predefinedComboBox.getSelectedItem();
        if (PageSetupDialog.access$000(this.this$0))
          if (ComparatorUtils.equals(Locale.CHINA, FRContext.getLocale()))
            this.showPagePane.populate(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth()), BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight()), i, true);
          else
            this.showPagePane.populate(localPaperSize.getWidth(), localPaperSize.getHeight(), i, false);
        else
          this.showPagePane.populate(BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getWidth()), BaseCoreUtils.convertInchesToMillimeters(localPaperSize.getHeight()), i, true);
      }
      else if (this.customRadioButton.isSelected())
      {
        this.showPagePane.populate(((Number)this.paperWidthSpinner.getValue()).doubleValue(), ((Number)this.paperHeightSpinner.getValue()).doubleValue(), i, (!(PageSetupDialog.access$000(this.this$0))) || (ComparatorUtils.equals(Locale.CHINA, FRContext.getLocale())));
      }
      this.showPagePane.repaint();
    }

    private JPanel createIconRadioPane(, JRadioButton paramJRadioButton)
    {
      JPanel localJPanel = new JPanel();
      localJPanel.setLayout(new FlowLayout(1));
      localJPanel.add(new JLabel(paramIcon));
      localJPanel.add(paramJRadioButton);
      return localJPanel;
    }

    static void access$100(PagePane paramPagePane)
    {
      paramPagePane.previewShowPagePane();
    }

    static PageSetupDialog access$200(PagePane paramPagePane)
    {
      return paramPagePane.this$0;
    }

    static JComboBox access$300(PagePane paramPagePane)
    {
      return paramPagePane.predefinedComboBox;
    }

    static JSpinner access$400(PagePane paramPagePane)
    {
      return paramPagePane.paperWidthSpinner;
    }

    static JSpinner access$500(PagePane paramPagePane)
    {
      return paramPagePane.paperHeightSpinner;
    }

    static JRadioButton access$600(PagePane paramPagePane)
    {
      return paramPagePane.predefinedRadioButton;
    }

    static JRadioButton access$700(PagePane paramPagePane)
    {
      return paramPagePane.customRadioButton;
    }

    class ShowPagePane extends JPanel
    {
      private double paper_width;
      private double paper_height;
      private int paper_orientation;
      private int pane_width;
      private int pane_height;
      private double length_scale;
      private Image img;
      private final PageSetupDialog.PagePane this$1;

      public ShowPagePane()
      {
        this.this$1 = paramPagePane;
        this.pane_width = 300;
        this.pane_height = 100;
        this.length_scale = 0.3D;
        setSize(this.pane_width, this.pane_height);
        setPreferredSize(new Dimension(this.pane_width, this.pane_height));
        setBackground(new Color(128, 128, 128));
        setOpaque(false);
        this.img = BaseUtils.readImage("/com/fr/dialog/images/pagesetup/a.png");
      }

      public void populate(, double paramDouble2, int paramInt, boolean paramBoolean)
      {
        if ((paramDouble1 <= 0.0D) || (paramDouble2 <= 0.0D))
          return;
        this.paper_width = Math.min(paramDouble1, 2000.0D);
        this.paper_height = Math.min(paramDouble2, 2000.0D);
        this.paper_orientation = paramInt;
        this.length_scale = ((!(paramBoolean)) ? 3.0D : 0.3D);
      }

      public void paintComponent()
      {
        super.paintComponent(paramGraphics);
        if ((this.paper_width > 0.0D) && (this.paper_height > 0.0D))
        {
          double d3 = this.length_scale * this.paper_width / (this.pane_width - 50);
          double d4 = this.length_scale * this.paper_height / (this.pane_height - 30);
          if ((d3 > 1.0D) || (d4 > 1.0D))
          {
            double d5 = (d3 > d4) ? d3 : d4;
            d1 = this.length_scale * this.paper_width / d5;
            d2 = this.length_scale * this.paper_height / d5;
          }
          else
          {
            d1 = this.paper_width * this.length_scale;
            d2 = this.paper_height * this.length_scale;
          }
          Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
          FontMetrics localFontMetrics = localGraphics2D.getFontMetrics();
          String str1 = "" + this.paper_width;
          if (str1.indexOf(".") > 0)
            str1 = str1.substring(0, str1.indexOf(".") + 2);
          int i = localFontMetrics.stringWidth(str1);
          double d1 = Math.max(d1, i + 26);
          String str2 = "" + this.paper_height;
          if (str2.indexOf(".") > 0)
            str2 = str2.substring(0, str2.indexOf(".") + 2);
          int j = localFontMetrics.stringWidth(str2);
          double d2 = Math.max(d2, j + 26);
          double d6 = (this.pane_width - d1) / 2.0D;
          double d7 = (this.pane_height - d2) / 2.0D;
          localGraphics2D.translate(d6, d7);
          localGraphics2D.setColor(Color.WHITE);
          localGraphics2D.fill3DRect(0, 0, (int)d1, (int)d2, true);
          localGraphics2D.setColor(Color.BLACK);
          localGraphics2D.drawLine(0, -5, 0, -15);
          localGraphics2D.drawLine((int)d1 - 1, -5, (int)d1 - 1, -15);
          localGraphics2D.drawString(str1, (int)((d1 - i) / 2.0D), -5);
          localGraphics2D.drawLine(2, -10, (int)((d1 - i) / 2.0D) - 5, -10);
          localGraphics2D.drawLine((int)((d1 + i) / 2.0D) + 5, -10, (int)d1 - 3, -10);
          localGraphics2D.drawLine(2, -10, 7, -13);
          localGraphics2D.drawLine(2, -10, 7, -7);
          localGraphics2D.drawLine((int)d1 - 3, -10, (int)d1 - 8, -13);
          localGraphics2D.drawLine((int)d1 - 3, -10, (int)d1 - 8, -7);
          localGraphics2D.drawLine(-15, 0, -5, 0);
          localGraphics2D.drawLine(-15, (int)d2 - 1, -5, (int)d2 - 1);
          localGraphics2D.rotate(-Math.toRadians(90.0D));
          localGraphics2D.drawString(str2, -(int)((d2 + j) / 2.0D), -5);
          localGraphics2D.rotate(Math.toRadians(90.0D));
          localGraphics2D.drawLine(-10, 2, -10, (int)((d2 - j) / 2.0D) - 5);
          localGraphics2D.drawLine(-10, (int)((d2 + j) / 2.0D) + 5, -10, (int)d2 - 3);
          localGraphics2D.drawLine(-10, 2, -13, 7);
          localGraphics2D.drawLine(-10, 2, -7, 7);
          localGraphics2D.drawLine(-10, (int)d2 - 3, -13, (int)d2 - 8);
          localGraphics2D.drawLine(-10, (int)d2 - 3, -7, (int)d2 - 8);
          if (this.paper_orientation == 0)
          {
            localGraphics2D.drawImage(this.img, (int)((d1 - this.img.getWidth(null)) / 2.0D), (int)((d2 - this.img.getHeight(null)) / 2.0D), null);
          }
          else
          {
            localGraphics2D.rotate(-Math.toRadians(90.0D));
            localGraphics2D.drawImage(this.img, -(int)((d2 + this.img.getWidth(null)) / 2.0D), (int)((d1 - this.img.getHeight(null)) / 2.0D), null);
            localGraphics2D.rotate(Math.toRadians(90.0D));
          }
          localGraphics2D.translate(-d6, -d7);
        }
      }
    }
  }
}